﻿@{this.Init(layout: "~/_SiteLayout.cshtml", title: "Password Reset", action:Account.PasswordReset.Init);}
 
@if (!Page.IsValid) {
    <p class="message error">
        @if (Page.Errors.ResetToken.IsError) {
            <text>The password reset token is incorrect or may be expired. Visit the <a href="@Href("~/Account/ForgotPassword")">forgot password page</a> to generate a new one.</text>
        } else {
            <text>Could not reset password. Please correct the errors and try again.</text>
        }
    </p>
}

@if (Page.Success) {
    <p class="message success">
        Password changed! Click <a href="@Href("~/Account/Login")" title="Login">here</a> to login.
    </p>
}

<form method="post" action="">
    <fieldset>
        <legend>Password Change Form</legend>
        @if (!WebMail.SmtpServer.IsEmpty()) {
            <p>Please type in your new password below and click the <em>Reset Password</em> button to change your password.</p>
            <ol>
                <li class="new-password">
                    <label for="newPassword">New Password:</label> 
                    <input type="password" id="newPassword" name="newPassword" title="New Password" @if(Page.Success){<text>disabled="disabled"</text>} @if(Page.Errors.NewPassword.IsError){<text>class="error-field"</text>} />
                    @if (Page.Errors.NewPassword.IsError) {
                        <label for="newPassword" class="validation-error">@Page.Errors.NewPassword.Message</label>
                    }
                </li>
                <li class="confirm-password">
                    <label for="confirmPassword">Confirm Password:</label> 
                    <input type="password" id="confirmPassword" name="confirmPassword" title="Confirm new password" @if(Page.Success){<text>disabled="disabled"</text>} @if(Page.Errors.ConfirmPassword.IsError){<text>class="error-field"</text>} />
                    @if (Page.Errors.ConfirmPassword.IsError) {
                        <label for="confirmPassword" class="validation-error">@Page.Errors.ConfirmPassword.Message</label>
                    }
                </li>
                <li class="reset-token">
                    <label for="resetToken">Password Reset Token:</label> 
                    <input type="text" id="resetToken" name="resetToken" value="@Page.Model.ResetToken" title="Password reset token" @if(Page.Success){<text>disabled="disabled"</text>} @if(Page.Errors.ResetToken.IsError){<text>class="error-field"</text>} />
                    @if (Page.Errors.ResetToken.IsError) {
                        <label for="resetToken" class="validation-error">@Page.Errors.ResetToken.Message</label>
                    }
                </li>
            </ol>
            <p class="form-actions">
                <input type="submit" value="Reset Password" title="Reset password" @if(Page.Success){<text>disabled="disabled"</text>} />
            </p>
        } else {
            <p class="message info">
                Password recovery is disabled for this website because the SMTP server is 
                not configured correctly. Please contact the owner of this site to reset 
                your password.
            </p>
        }
    </fieldset>
</form>